package com.mars.diancan.pojo;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.mars.diancan.common.ProductStatusEnum;
import com.mars.diancan.utils.EnumUtil;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.annotations.DynamicUpdate;

import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import java.math.BigDecimal;
import java.util.Date;

/**
 * 商品信息
 * @author MARS
 * @date 2018/6/21
 */

@Table(name = "wx_product_info")
@Entity
@DynamicUpdate
@Data
@NoArgsConstructor
@AllArgsConstructor
public class ProductInfo {

    @Id
    private String productId;

    private String productName;

    private BigDecimal productPrice;

    private Integer productStock;

    private String productDescription;

    private String productIcon;

    private Integer categoryType;

    private Integer productStatus = ProductStatusEnum.UP.getCode();

    private Date createTime;

    private Date updateTime;

    // 添加枚举属性 表示状态
    @JsonIgnore
    public ProductStatusEnum getProductStatusEnum(){
        return EnumUtil.getByCode(productStatus,ProductStatusEnum.class);
    }


}
